import java.util.Stack;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * Date: 2024-02-03
 * Time:9:15
 */
public class Solution1 {
    Stack<Integer> stack = new Stack<>();

    public boolean IsPopOrder (int[] pushV, int[] popV) {
        int len = pushV.length;
        int j = 0;
        for(int i = 0;i < len;i++) {
            stack.push(pushV[i]);
            while(!stack.isEmpty() && stack.peek() == popV[j]) {
                stack.pop();
                ++j;
            }

        }
        return stack.isEmpty();
    }

}
